<!DOCTYPE html><html><head><title>README</title><link href="http://www.jboss.org/jdf/stylesheets/documentation.css" rel="stylesheet"></link><link href="http://www.jboss.org/jdf/stylesheets/pygments.css" rel="stylesheet"></link></head><body>
<h1><a id="h2console-example-using-the-h2-console-with-jboss" class="anchor" href="#h2console-example-using-the-h2-console-with-jboss"><span class="anchor-icon"></span></a>h2-console: Example Using the H2 Console with JBoss</h1>

<p>Author: Pete Muir<br/>
Level: Beginner<br/>
Technologies: H2<br/>
Summary: Shows how to use the H2 console with JBoss AS<br/>
Target Product: EAP<br/>
Product Versions: EAP 6.1, EAP 6.2<br/>
Source: <a href="https://github.com/jboss-developer/jboss-eap-quickstarts/">https://github.com/jboss-developer/jboss-eap-quickstarts/</a>  </p>

<h2><a id="what-is-it" class="anchor" href="#what-is-it"><span class="anchor-icon"></span></a>What is it?</h2>

<p>JBoss AS bundles H2 as an in-memory, in-process database. H2 is written in Java so can run on any platform JBoss AS runs.</p>

<p>This is quickstart shows you how to use the H2 console with Red Hat JBoss Enterprise Application Platform. It uses the <code>greeter</code> quickstart as a GUI for entering data.</p>

<p><em>Note: This quickstart uses the H2 database included with JBoss EAP 6. It is a lightweight, relational example datasource that is used for examples only. It is not robust or scalable and should NOT be used in a production environment!</em></p>

<h2><a id="system-requirements" class="anchor" href="#system-requirements"><span class="anchor-icon"></span></a>System requirements</h2>

<p>The application this project produces is designed to be run on Red Hat JBoss Enterprise Application Platform 6.1 or later. </p>

<p>All you need to build this project is Java 6.0 (Java SDK 1.6) or later, Maven 3.0 or later.</p>

<h2><a id="configure-maven" class="anchor" href="#configure-maven"><span class="anchor-icon"></span></a>Configure Maven</h2>

<p>If you have not yet done so, you must <a href="../README.html#configure-maven">Configure Maven</a> before testing the quickstarts.</p>

<h2><a id="prerequisites" class="anchor" href="#prerequisites"><span class="anchor-icon"></span></a>Prerequisites</h2>

<p>This quickstart depends on the deployment of the &lsquo;greeter&rsquo; quickstart. Before running this quickstart, see the <a href="../greeter/README.html">greeter README</a> file for details on how to deploy it.</p>

<p>You can verify the deployment of the <code>greeter</code> quickstart by accessing the following URL: <a href="http://localhost:8080/jboss-greeter">http://localhost:8080/jboss-greeter</a> </p>

<h2><a id="deploy-the-h2-console" class="anchor" href="#deploy-the-h2-console"><span class="anchor-icon"></span></a>Deploy the H2 Console</h2>

<p>This quickstart comes bundled with a version of the H2 Console built for JBoss EAP. The changes that have been made to the stock console are described below. </p>

<p>Deploy the console by copying the <code>QUICKSTART_HOME/h2-console/h2console.war</code> to the <code>$JBOSS_HOME/standalone/deployments</code> directory. </p>

<h2><a id="access-the-h2-console-" class="anchor" href="#access-the-h2-console-"><span class="anchor-icon"></span></a>Access the H2 Console </h2>

<p>You can access the console at the following URL:  <a href="http://localhost:8080/h2console">http://localhost:8080/h2console</a>.</p>

<p>You need to enter the JDBC URL, and credentials. To access the &ldquo;test&rdquo; database that the <code>greeter</code> quickstart uses, enter these details:</p>

<ul>
<li>JDBC URL: <code>jdbc:h2:mem:greeter-quickstart;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1</code></li>
<li>User Name: <code>sa</code></li>
<li>Password: <code>sa</code></li>
</ul>

<p>Click on the <em>Test Connection</em> button to make sure you can connect. If you can, go ahead and click <em>Connect</em>.</p>

<h2><a id="investigate-the-h2-console" class="anchor" href="#investigate-the-h2-console"><span class="anchor-icon"></span></a>Investigate the H2 Console</h2>

<p>Take a look at the data added by the <code>greeter</code> application. Run the following SQL command:</p>
<div class="highlight"><pre>    <span class="n">select</span> <span class="o">*</span> <span class="n">from</span> <span class="n">users</span><span class="p">;</span>
</pre></div>
<p>You should see the two users seeded by the <code>greeter</code> quickstart, plus any users you added when testing that application.</p>

<h2><a id="changes-to-the-h2-console-for-jboss-eap" class="anchor" href="#changes-to-the-h2-console-for-jboss-eap"><span class="anchor-icon"></span></a>Changes to the H2 Console for JBoss EAP</h2>

<p>To make the H2 console run on JBoss EAP, the H2 libraries were removed from the WAR and a dependency on the H2 module was added to the META-INF/MANIFEST.MF fle. The rebuilt console is provided with this quickstart.</p>
</body></html>
